package com.job.client.company.controller;


import cn.hutool.core.text.replacer.StrReplacer;
import com.job.client.common.result.ResponseResult;
import com.job.client.company.service.CompanyService;
import com.job.client.model.company.dto.CompanyAuth;
import com.job.client.model.company.pojo.Company;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 公司详情表 前端控制器
 * </p>
 *
 * @author fkl
 * @since 2023-12-07
 */
@RestController
@RequestMapping("/api/v1/client/company")
@Api(tags = "公司服务接口文档")
public class CompanyController {
    @Autowired
    private CompanyService companyService;

    @GetMapping("/{companyId}")
    @ApiOperation("根据id获得公司信息")
    public ResponseResult getCompanyById(@PathVariable String companyId){
        return companyService.getCompanyById(companyId);
    }
    @PostMapping("/info/list")
    @ApiOperation("根据companyIds数组返回companyInfo数组")
    public ResponseResult getCompanyInfoByList(@RequestBody List<String> companyIds){
        return companyService.getCompanyInfoByList(companyIds);
    }
    @PostMapping("/auth")
    @ApiOperation("用户的企业认证")
    public ResponseResult authUser(@RequestBody String authStr, HttpServletRequest request){
        return companyService.authUser(authStr,request);
    }

    @PostMapping("/authCompany")
    @ApiOperation("创建公司，需要进行审核")
    public ResponseResult authCompany(@RequestBody CompanyAuth companyAuth,HttpServletRequest request){
        return companyService.companyAuth(companyAuth,request);
    }

    @PostMapping("/uploadProfile")
    @ApiOperation("上传公司头像像到minio")
    public ResponseResult uploadProfile(@RequestParam MultipartFile file, HttpServletRequest request){
        return companyService.uploadProfile(file,request);
    }

    @PostMapping("/uploadCompanyImage")
    @ApiOperation("上传公司相册像到minio")
    public ResponseResult uploadCompanyImage(@RequestParam MultipartFile file, HttpServletRequest request){
        return companyService.uploadCompanyImage(file,request);
    }

    @PostMapping("/update/profile")
    @ApiOperation("修改公司头像")
    public ResponseResult updateProfile(@RequestParam String companyId,@RequestParam String profilePicture){
        return companyService.updateProfile(companyId,profilePicture);
    }

    @PostMapping("/update/company")
    @ApiOperation("修改公司数据")
    public ResponseResult updateCompany(@RequestBody Company company){
        return companyService.updateCompany(company);
    }

    @GetMapping("/posts/boss/count")
    @ApiOperation("根据公司id获得当前公司拥有的职位和boss人数")
    public ResponseResult getCountByCompanyId(@RequestParam String companyId){
        return companyService.getCountByCompanyId(companyId);
    }

}
